<?php
/**
 * Created by JetBrains PhpStorm.
 * User: developerphp
 * Date: 9/27/12
 * Time: 11:10 AM
 * To change this template use File | Settings | File Templates.
 */

class  Page_Be_Scheme extends Page {

	public function defaultAction() {
		self::$TPL->appendJsFile('admin/kinetic-v4.0.2.min');
		self::$TPL->appendJsFile('admin/scheme');
		self::$TPL->setBodyTemplate("scheme");

		return array (
		'type'=> 'display'
		);
	}

	public function ajaxGetCategoriesAction() {
		$categories = Db_Products_Categories::getCategories();
		$projects = Db_Projects::getProjects();
        $menus = Db_Cms_Menus::getMenus();
		$pagesList = Db_Cms_Pages::findAllArray("id, p_name");
		$pages = array();
		foreach ($pagesList as $page) {
			$pages[$page['id']]['id'] = "pag".$page['id'];
			$pages[$page['id']]['name'] = isset($page['p_name']) && $page['p_name'] != NULL ? t(T_PAGE_TITLE, $page['p_name']) : t(T_PAGE_TITLE, "no_name");
		}
		$productsList = Db_Products_Products::findAllArray("id, p_name");
		$products = array();
		foreach ($productsList as $product) {
			$products[$product['id']]['id'] = "prod".$product['id'];
			$products[$product['id']]['name'] = t(T_PRODUCTS_TITLE, $product['p_name']);
		}
		$json['products'] = array_values($products);
		$json['pages'] = array_values($pages);
		$json['menus'] = $menus;
		$json['categories'] = $categories;
		$json['projects'] = $projects;
		return array(
			'type' => 'json',
			'content' => $json
		);
	}
}




